﻿<Window x:Class="HRM.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:ignore="http://www.ignore.com"
        xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
        xmlns:local="clr-namespace:HRM.CustomControl"
        mc:Ignorable="d ignore"
        Title="{StaticResource Title}"
        DataContext="{Binding Main, Source={StaticResource Locator}}" Loaded="Window_Loaded">

    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/Skins/MainSkin.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Window.Resources>

    <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Menu IsMainMenu="True" Height="Auto" VerticalAlignment="Top" Grid.Row="0">
            <MenuItem Header="Menu">
                <MenuItem Header="Đăng xuất" Click="Logout_Click"/>
                <MenuItem Header="Thoát" Click="Exit_Click"/>
            </MenuItem>
            <MenuItem Header="Tools" />
            <MenuItem Header="Help" />
        </Menu>


        <Grid Grid.Row="2">
            <Grid.ColumnDefinitions>
                <ColumnDefinition MinWidth="100" MaxWidth="500" Width="200"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="50*" />
            </Grid.ColumnDefinitions>
            <Grid Grid.Column="0">
                <ListBox x:Name="lbMain" ItemsSource="{Binding FunctionsView}" Style="{StaticResource ListBoxContainerStyle}" ItemContainerStyle="{DynamicResource ListBoxItemStyle}" SelectedItem="{Binding SelectedFunction, Mode=TwoWay}" >
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="SelectionChanged">
                            <i:InvokeCommandAction Command="{Binding ListBoxSelectionCommand}" />
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                    <ListBox.GroupStyle>
                        <GroupStyle ContainerStyle="{StaticResource ContainerStyle}" />
                    </ListBox.GroupStyle>
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Ten}" />
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </Grid>

            <GridSplitter Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Stretch" Width="5" ResizeBehavior="PreviousAndNext" BorderBrush="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}" BorderThickness="0,0,1,0"/>

            <Grid Grid.Column="2">
                <Grid.RowDefinitions>
                    <RowDefinition Height="*" />
                    <RowDefinition Height="30" />
                </Grid.RowDefinitions>
                <Grid Grid.Row="0">
                    <!--Phan quyen-->
                    <Grid Visibility="{Binding SelectedItem, ConverterParameter=1, Converter={StaticResource ConvertFunctionToVisible}, ElementName=lbMain}" DataContext="{Binding GroupUserViewModel}">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <ListBox ItemsSource="{Binding ListEntities}" Grid.Column="0" SelectedItem="{Binding SelectedItem, Mode=TwoWay}">
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding TenNhom}" />
                                </DataTemplate>
                            </ListBox.ItemTemplate>
                        </ListBox>
                        <ListBox ItemsSource="{Binding Main.Functions, Source={StaticResource Locator}}" Grid.Column="1" SelectedItem="{Binding FunctionSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                    <ListBoxItem>
                                        <CheckBox Content="{Binding Ten}" IsChecked="{Binding IsChecked}" Command="{Binding Main.GroupUserViewModel.ChangingCommand, Source={StaticResource Locator}, UpdateSourceTrigger=PropertyChanged}" CommandParameter="{Binding MaChucNang}"/>
                                    </ListBoxItem>
                                </DataTemplate>
                            </ListBox.ItemTemplate>
                        </ListBox>
                        <Grid Grid.Column="2">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="30"/>
                                <RowDefinition Height="*"/>
                            </Grid.RowDefinitions>
                            <ToolBar Grid.Row="0">

                                <Button ToolTip="Sắp xếp A - Z">
                                    <Button.Content>
                                        <Image Source="/Assets/Icons/sort-ascend.png" />
                                    </Button.Content>
                                </Button>

                                <Button ToolTip="Sắp xếp Z - A">
                                    <Button.Content>
                                        <Image Source="/Assets/Icons/sort-descend.png" />
                                    </Button.Content>
                                </Button>
                            </ToolBar>

                            <ListBox ItemsSource="{Binding SelectedItem.NguoiSuDungs}" Grid.Row="1" SelectedItem="{Binding SelectedUser}">
                                <ListBox.ItemTemplate>
                                    <DataTemplate>
                                        <TextBlock>
                                        <Run Text="{Binding TenDangNhap}" />
                                        <Run Text=" - " />
                                        <Run Text="{Binding NhanVien.HoTen}" FontWeight="Bold" />
                                        </TextBlock>
                                    </DataTemplate>
                                </ListBox.ItemTemplate>
                                <ListBox.ItemContainerStyle>
                                    <Style TargetType="ListBoxItem">
                                        <Setter Property="ContextMenu">
                                            <Setter.Value>
                                                <ContextMenu DataContext="{Binding Main.GroupUserViewModel, Source={StaticResource Locator}}">
                                                    <MenuItem Header="Xem chi tiết" Command="{Binding DetailCommand}">
                                                        <MenuItem.Icon>
                                                            <Image Source="/Assets/Icons/detail.png" />
                                                        </MenuItem.Icon>
                                                    </MenuItem>
                                                    <MenuItem Header="Loại bỏ" Command="{Binding RemoveCommand}">
                                                        <MenuItem.Icon>
                                                            <Image Source="/Assets/Icons/remove.png" />
                                                        </MenuItem.Icon>
                                                    </MenuItem>

                                                    <MenuItem Header="Chuyển nhóm" Command="{Binding ForwardCommand}" CommandParameter="{Binding SelectedUser}">
                                                        <MenuItem.Icon>
                                                            <Image Source="/Assets/Icons/forward.png" />
                                                        </MenuItem.Icon>
                                                    </MenuItem>
                                                </ContextMenu>
                                            </Setter.Value>
                                        </Setter>

                                    </Style>
                                </ListBox.ItemContainerStyle>
                            </ListBox>
                        </Grid>

                    </Grid>

                    <!--Nguoi su dung-->
                    <Grid Visibility="{Binding SelectedItem, ConverterParameter=2, Converter={StaticResource ConvertFunctionToVisible}, ElementName=lbMain}" DataContext="{Binding UserViewModel}">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="*" />
                            <RowDefinition Height="30" />
                        </Grid.RowDefinitions>

                        <Grid Grid.Row="0" Margin="5,0,0,5" DataContext="{Binding SelectedItem,Mode=TwoWay}">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="5"/>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="5"/>
                                <ColumnDefinition Width="180"/>
                                <ColumnDefinition Width="5"/>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="5"/>
                                <ColumnDefinition Width="150"/>
                            </Grid.ColumnDefinitions>

                            <StackPanel Grid.Row="0" Grid.ColumnSpan="10" Orientation="Horizontal" DataContext="{Binding DataContext.UserViewModel, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}">
                                <RadioButton IsChecked="{Binding AddMode, Mode=TwoWay}" Margin="3">Thêm</RadioButton>
                                <RadioButton IsChecked="{Binding UpdateMode, Mode=TwoWay}" Margin="3">Sửa</RadioButton>
                            </StackPanel>
                            <TextBlock Grid.Row="1" Grid.Column="0" Text="Mã nhân viên" Style="{StaticResource TextBlockStyle}" />
                            <TextBlock Grid.Row="3" Grid.Column="0" Text="Nhân viên" Style="{StaticResource TextBlockStyle}" />

                            <TextBox Grid.Row="1" Grid.Column="2" Text="{Binding NhanVien.MaNhanVien}" Style="{StaticResource TextBoxStyle}" IsReadOnly="True"/>
                            <ComboBox Grid.Row="3" Grid.Column="2" ItemsSource="{Binding Staffs}" DataContext="{Binding Main.UserViewModel, Source={StaticResource Locator}}" SelectedItem="{Binding StaffSelected, Mode=TwoWay}" Height="30" IsReadOnly="{Binding UpdateMode}">
                                <ComboBox.ItemTemplate>
                                    <DataTemplate>
                                        <StackPanel Orientation="Horizontal" Margin="3,0,0,3">
                                            <Image Source="{Binding AvatarSource}" Height="30"/>
                                            <TextBlock Text="{Binding HoTen}" HorizontalAlignment="Left" VerticalAlignment="Center"/>
                                        </StackPanel>
                                    </DataTemplate>
                                </ComboBox.ItemTemplate>
                            </ComboBox>

                            <TextBlock Grid.Row="1" Grid.Column="4" Text="Nhóm" Style="{StaticResource TextBlockStyle}"/>
                            <ComboBox Grid.Row="1" Grid.Column="6" ItemsSource="{Binding Groups}" DataContext="{Binding Main.UserViewModel, Source={StaticResource Locator}}" SelectedItem="{Binding GroupSelected, Mode=TwoWay}" >
                                <ComboBox.ItemTemplate>
                                    <DataTemplate>
                                        <TextBlock Text="{Binding TenNhom}" />
                                    </DataTemplate>
                                </ComboBox.ItemTemplate>
                            </ComboBox>

                            <TextBlock Grid.Row="3" Grid.Column="4" Text="Tên đăng nhập" Style="{StaticResource TextBlockStyle}" />
                            <TextBox Grid.Row="3" Grid.Column="6" Text="{Binding TenDangNhap, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource TextBoxStyle}"/>
                        </Grid>

                        <Grid Grid.Row="1">
                            <ToolBar>
                                <Button Command="{Binding SaveCommand, UpdateSourceTrigger=PropertyChanged}">
                                    <Button.Content>
                                        <StackPanel Orientation="Horizontal">
                                            <Image Source="/Assets/Icons/save.png" Height="20"/>
                                            <TextBlock Text="Lưu" VerticalAlignment="Center" Margin="3,0,3,0" />
                                        </StackPanel>
                                    </Button.Content>

                                </Button>
                                <Button Command="{Binding DeleteListCommand, UpdateSourceTrigger=PropertyChanged}">
                                    <Button.Content>
                                        <StackPanel Orientation="Horizontal">
                                            <Image Source="/Assets/Icons/delete.png" Height="20"/>
                                            <TextBlock Text="Xóa" VerticalAlignment="Center" Margin="3,0,3,0" />
                                        </StackPanel>
                                    </Button.Content>
                                </Button>

                                <Button Command="{Binding RefreshCommand, UpdateSourceTrigger=PropertyChanged}">
                                    <Button.Content>
                                        <StackPanel Orientation="Horizontal">
                                            <Image Source="/Assets/Icons/sync.png" Height="20"/>
                                            <TextBlock Text="Làm tươi" VerticalAlignment="Center" Margin="3,0,3,0" />
                                        </StackPanel>
                                    </Button.Content>
                                </Button>

                            </ToolBar>

                            <TextBlock HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,20,0" >
                                <Run Text="Total: " />
                                <Run Text="{Binding TotalItems}" FontWeight="Bold" />
                                <Run Text=" items" />
                            </TextBlock>
                        </Grid>

                        <DataGrid Grid.Row="2" ItemsSource="{Binding ListEntities, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource DataGridStyle}" SelectedItem="{Binding SelectedItem, Mode=TwoWay}">
                            <DataGrid.Columns>
                                <DataGridCheckBoxColumn Binding="{Binding IsChecked, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsReadOnly="False">
                                    <DataGridCheckBoxColumn.HeaderTemplate>
                                        <DataTemplate>
                                            <CheckBox Command="{Binding Main.UserViewModel.CheckAllCommand}" DataContext="{StaticResource Locator}" CommandParameter="{Binding IsChecked, RelativeSource={RelativeSource Self}, UpdateSourceTrigger=PropertyChanged}"/>
                                        </DataTemplate>
                                    </DataGridCheckBoxColumn.HeaderTemplate>
                                </DataGridCheckBoxColumn>
                                <DataGridTextColumn Header="Mã nhân viên" Binding="{Binding NhanVien.MaNhanVien}" Width="Auto" IsReadOnly="True"/>
                                <DataGridTextColumn Header="Tên nhân viên" Binding="{Binding NhanVien.HoTen}" Width="*" IsReadOnly="True"/>
                                <DataGridTextColumn Header="Tên đăng nhập" Binding="{Binding TenDangNhap}" Width="*" IsReadOnly="True"/>
                                <DataGridTextColumn Header="Nhóm" Binding="{Binding NhomNguoiDung.TenNhom}" Width="*" IsReadOnly="True"/>
                                <DataGridTemplateColumn Header="Chức năng">
                                    <DataGridTemplateColumn.CellTemplate>
                                        <DataTemplate>
                                            <Button Content="Xóa" Command="{Binding Main.UserViewModel.DeleteCommand}" DataContext="{StaticResource Locator}" CommandParameter="{Binding SelectedItem, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"/>
                                        </DataTemplate>
                                    </DataGridTemplateColumn.CellTemplate>
                                </DataGridTemplateColumn>
                            </DataGrid.Columns>
                        </DataGrid>

                        <local:PagingControl Grid.Row="3" FirstPageCommand="{Binding FirstPageCommand}" PreviosPageCommand="{Binding PreviosPageCommand}" NextPageCommand="{Binding NextPageCommand}" LastPageCommand="{Binding LastPageCommand}" PageIndex="{Binding PageIndex, Mode=TwoWay}" PageSize="{Binding PageSize, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" NumberOfPages="{Binding NumberOfPages, Mode=OneWay}"/>
                    </Grid>

                    <!--Chức năng-->
                    <Grid Visibility="{Binding SelectedItem, ConverterParameter=4, Converter={StaticResource ConvertFunctionToVisible}, ElementName=lbMain}" DataContext="{Binding FunctionViewModel}" d:DataContext="{Binding }">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="*" />
                        </Grid.RowDefinitions>

                        <StackPanel Grid.Row="0" Orientation="Horizontal">
                            <GroupBox Grid.Row="0" Header="Thông tin" Padding="5" Margin="0,0,0,10" HorizontalAlignment="Left">
                                <Grid d:DataContext="{Binding Functions[0]}" DataContext="{Binding SelectedItem}">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="10"/>
                                        <ColumnDefinition Width="200"/>
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition />
                                        <RowDefinition Height="5"/>
                                        <RowDefinition />
                                        <RowDefinition Height="5"/>
                                        <RowDefinition />
                                    </Grid.RowDefinitions>

                                    <TextBlock Grid.Row="0" Grid.Column="0" Text="Mã chức năng" Style="{StaticResource TextBlockStyle}"/>
                                    <TextBox Grid.Row="0" Grid.Column="3" Text="{Binding MaChucNang, Mode=TwoWay}" Style="{StaticResource TextBoxStyle}"/>
                                    <TextBlock Grid.Row="2" Grid.Column="0" Text="Tên chức năng" Style="{StaticResource TextBlockStyle}"/>
                                    <TextBox Grid.Row="2" Grid.Column="3" Text="{Binding Ten, Mode=TwoWay}" Style="{StaticResource TextBoxStyle}"/>
                                    <TextBlock Grid.Row="4" Grid.Column="0" Text="Nhóm" Style="{StaticResource TextBlockStyle}"/>
                                    <TextBox Grid.Row="5" Grid.Column="3" Text="{Binding Nhom, Mode=TwoWay}" Style="{StaticResource TextBoxStyle}"/>
                                </Grid>
                            </GroupBox>
                            <Button Width="100" Style="{StaticResource ButtonStyle}" Content="Lưu lại" Margin="10" VerticalAlignment="Top" Command="{Binding SaveCommand}"/>
                        </StackPanel>


                        <DataGrid ItemsSource="{Binding Functions}" Style="{StaticResource DataGridStyle}" Grid.Row="1" SelectedItem="{Binding SelectedItem, Mode=TwoWay}">
                            <DataGrid.Columns>
                                <DataGridTextColumn Binding="{Binding MaChucNang}" Header="Mã chức năng" Width="Auto"/>
                                <DataGridTextColumn Binding="{Binding Ten}" Header="Tên chức năng" Width="*"/>
                                <DataGridTextColumn Binding="{Binding Nhom}" Header="Nhóm" Width="*"/>
                            </DataGrid.Columns>
                        </DataGrid>
                    </Grid>

                    <!--Quản lý nhân viên id=5-->
                    <Grid Visibility="{Binding SelectedItem, ConverterParameter=5, Converter={StaticResource ConvertFunctionToVisible}, ElementName=lbMain}" DataContext="{Binding StaffViewModel}">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="*" />
                            <RowDefinition Height="30" />
                        </Grid.RowDefinitions>

                        <Grid Grid.Row="0" Margin="5,0,0,5" DataContext="{Binding SelectedItem,Mode=TwoWay}">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="5"/>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="5"/>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="5"/>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="5"/>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="5"/>
                                <ColumnDefinition Width="150"/>
                                <ColumnDefinition Width="5"/>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="5"/>
                                <ColumnDefinition Width="150"/>
                                <ColumnDefinition Width="5"/>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="5"/>
                                <ColumnDefinition Width="150"/>
                                <ColumnDefinition Width="5"/>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="5"/>
                                <ColumnDefinition Width="150"/>
                            </Grid.ColumnDefinitions>

                            <StackPanel Grid.Row="0" Grid.ColumnSpan="20" Orientation="Horizontal" DataContext="{Binding DataContext.StaffViewModel, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}" Margin="0,0,0,10">
                                <RadioButton IsChecked="{Binding AddMode, Mode=TwoWay}" Margin="3">Thêm</RadioButton>
                                <RadioButton IsChecked="{Binding UpdateMode, Mode=TwoWay}" Margin="3">Sửa</RadioButton>
                            </StackPanel>

                            <Border Grid.Column="0" Grid.RowSpan="10" Height="110" Width="110" Grid.Row="1" BorderBrush="#FF856666" BorderThickness="1" ToolTip="Ảnh đại diện">
                                <Grid>
                                    <Image Source="{Binding AvatarSource}" />
                                    <Grid.ContextMenu>
                                        <ContextMenu DataContext="{Binding Main.StaffViewModel, Source={StaticResource Locator}}">
                                            <MenuItem Header="Đổi ảnh đại diện" Command="{Binding ChangeImageCommand}"></MenuItem>
                                        </ContextMenu>
                                    </Grid.ContextMenu>
                                </Grid>
                                
                            </Border>
                            <!--Column 2-->
                            <TextBlock Text="Mã nhân viên" Grid.Row="1" Grid.Column="2" Style="{StaticResource TextBlockStyle}" />
                            <TextBox Text="{Binding MaNhanVien, Converter={StaticResource ConvertZeroIDToAutoIndentity}}" Grid.Row="1" Grid.Column="4" Style="{StaticResource TextBoxStyle}" IsReadOnly="True"/>

                            <TextBlock Text="Họ tên" Grid.Row="3" Grid.Column="2" Style="{StaticResource TextBlockStyle}" />
                            <TextBox Text="{Binding HoTen, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Grid.Row="3" Grid.Column="4" Style="{StaticResource TextBoxStyle}" />

                            <TextBlock Text="Ngày Sinh" Grid.Row="5" Grid.Column="2" Style="{StaticResource TextBlockStyle}" />
                            <DatePicker Grid.Row="5" Grid.Column="4" Text="{Binding NgaySinh, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Height="24"/>

                            <TextBlock Text="Giới tính" Grid.Row="7" Grid.Column="2" Style="{StaticResource TextBlockStyle}" />
                            <ComboBox Grid.Row="7" Grid.Column="4" SelectedIndex="{Binding GioiTinh, Converter={StaticResource ConvertGenderToIndex}, Mode=TwoWay}">
                                <ComboBoxItem>
                                    Nam
                                </ComboBoxItem>
                                <ComboBoxItem>
                                    Nữ
                                </ComboBoxItem>
                            </ComboBox>
                            <!--Colum 3-->


                            <TextBlock Text="Số CMND" Grid.Row="1" Grid.Column="6" Style="{StaticResource TextBlockStyle}" />
                            <TextBox Text="{Binding CMND, Mode=TwoWay}" Grid.Row="1" Grid.Column="8" Style="{StaticResource TextBoxStyle}" />

                            <TextBlock Text="Ngày cấp CMND" Grid.Row="3" Grid.Column="6" Style="{StaticResource TextBlockStyle}" />
                            <DatePicker Grid.Row="3" Grid.Column="8" Text="{Binding NgayCapCMND, Mode=TwoWay}" Height="24"/>

                            <TextBlock Grid.Row="5" Grid.Column="6" Text="Nơi cấp" Style="{StaticResource TextBlockStyle}" />
                            <TextBox Grid.Row="5" Grid.Column="8" Text="{Binding NoiCapCMND, Mode=TwoWay}" Style="{StaticResource TextBoxStyle}" />

                            <TextBlock Grid.Row="7" Grid.Column="6" Text="Quê Quán" Style="{StaticResource TextBlockStyle}" />
                            <TextBox Grid.Row="7" Grid.Column="8" Text="{Binding QueQuan, Mode=TwoWay}" Style="{StaticResource TextBoxStyle}" />

                            <!--Column 3-->
                            <TextBlock Grid.Row="1" Grid.Column="10" Text="SDT" Style="{StaticResource TextBlockStyle}" />
                            <TextBox Grid.Row="1" Grid.Column="12" Text="{Binding SDT, Mode=TwoWay}" Style="{StaticResource TextBoxStyle}" />

                            <TextBlock Grid.Row="3" Grid.Column="10" Text="DiaChi" Style="{StaticResource TextBlockStyle}" />
                            <TextBox Grid.Row="3" Grid.Column="12" Text="{Binding DiaChi, Mode=TwoWay}" Style="{StaticResource TextBoxStyle}" />

                            <TextBlock Grid.Row="5" Grid.Column="10" Text="Email" Style="{StaticResource TextBlockStyle}" />
                            <TextBox Grid.Row="5" Grid.Column="12" Text="{Binding Email, Mode=TwoWay}" Style="{StaticResource TextBoxStyle}" />

                            <TextBlock Grid.Row="7" Grid.Column="10" Text="Mã số thuế" Style="{StaticResource TextBlockStyle}" />
                            <TextBox Grid.Row="7" Grid.Column="12" Text="{Binding MaSoThue, Mode=TwoWay}" Style="{StaticResource TextBoxStyle}" />

                            <!--Column 4-->
                            <TextBlock Grid.Row="1" Grid.Column="14" Text="Trình độ học vấn" Style="{StaticResource TextBlockStyle}" />
                            <ComboBox Grid.Row="1" Grid.Column="16" ItemsSource="{Binding EducationLevels}" DataContext="{Binding Main.StaffViewModel, Source={StaticResource Locator}}" SelectedItem="{Binding ELSelected, Mode=TwoWay}">
                                <ComboBox.ItemTemplate>
                                    <DataTemplate>
                                        <TextBlock Text="{Binding TenTrinhDo}" ToolTip="{Binding ChuyenNganh}"/>
                                    </DataTemplate>
                                </ComboBox.ItemTemplate>
                            </ComboBox>
                        </Grid>

                        <Grid Grid.Row="1">
                            <ToolBar>
                                <Button Command="{Binding SaveCommand, UpdateSourceTrigger=PropertyChanged}">
                                    <Button.Content>
                                        <StackPanel Orientation="Horizontal">
                                            <Image Source="/Assets/Icons/save.png" Height="20"/>
                                            <TextBlock Text="Lưu" VerticalAlignment="Center" Margin="3,0,3,0" />
                                        </StackPanel>
                                    </Button.Content>

                                </Button>
                                <Button Command="{Binding DeleteListCommand, UpdateSourceTrigger=PropertyChanged}">
                                    <Button.Content>
                                        <StackPanel Orientation="Horizontal">
                                            <Image Source="/Assets/Icons/delete.png" Height="20"/>
                                            <TextBlock Text="Xóa" VerticalAlignment="Center" Margin="3,0,3,0" />
                                        </StackPanel>
                                    </Button.Content>
                                </Button>

                                <Button Command="{Binding RefreshCommand, UpdateSourceTrigger=PropertyChanged}">
                                    <Button.Content>
                                        <StackPanel Orientation="Horizontal">
                                            <Image Source="/Assets/Icons/sync.png" Height="20"/>
                                            <TextBlock Text="Làm tươi" VerticalAlignment="Center" Margin="3,0,3,0" />
                                        </StackPanel>
                                    </Button.Content>
                                </Button>

                            </ToolBar>

                            <TextBlock HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,20,0" >
                                <Run Text="Total: " />
                                <Run Text="{Binding TotalItems}" FontWeight="Bold" />
                                <Run Text=" items" />
                            </TextBlock>
                        </Grid>

                        <DataGrid Grid.Row="2" ItemsSource="{Binding ListEntities, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource DataGridStyle}" SelectedItem="{Binding SelectedItem, Mode=TwoWay}">
                            <DataGrid.Columns>
                                <DataGridCheckBoxColumn Binding="{Binding IsChecked, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsReadOnly="False">
                                    <DataGridCheckBoxColumn.HeaderTemplate>
                                        <DataTemplate>
                                            <CheckBox Command="{Binding Main.StaffViewModel.CheckAllCommand}" DataContext="{StaticResource Locator}" CommandParameter="{Binding IsChecked, RelativeSource={RelativeSource Self}, UpdateSourceTrigger=PropertyChanged}"/>
                                        </DataTemplate>
                                    </DataGridCheckBoxColumn.HeaderTemplate>
                                </DataGridCheckBoxColumn>
                                <DataGridTextColumn Header="Mã nhân viên" Binding="{Binding MaNhanVien}" Width="Auto" IsReadOnly="True"/>
                                <DataGridTextColumn Header="Họ tên" Binding="{Binding HoTen}" Width="*" IsReadOnly="True"/>
                                <DataGridTextColumn Header="Ngày sinh" Binding="{Binding NgaySinh, Converter={StaticResource ConvertDataTimeToDateString}}" Width="Auto" IsReadOnly="True"/>
                                <DataGridTextColumn Header="Giới tính" Binding="{Binding GioiTinh, Converter={StaticResource ConvertBooleanToGender}}" Width="Auto" IsReadOnly="True"/>
                                <DataGridTextColumn Header="CMND" Binding="{Binding CMND}" Width="Auto" IsReadOnly="True"/>
                                <DataGridTextColumn Header="SDT" Binding="{Binding SDT}" Width="Auto" IsReadOnly="True"/>
                                <DataGridTextColumn Header="Dân tộc" Binding="{Binding DanToc}" Width="Auto" IsReadOnly="True"/>
                                <DataGridTextColumn Header="Email" Binding="{Binding Email}" Width="*" IsReadOnly="True"/>
                                <DataGridTextColumn Header="MST" Binding="{Binding MaSoThue}" Width="Auto" IsReadOnly="True"/>
                                <DataGridTemplateColumn Header="Chức năng" Width="Auto">
                                    <DataGridTemplateColumn.CellTemplate>
                                        <DataTemplate>
                                            <StackPanel Orientation="Horizontal" DataContext="{Binding Main.StaffViewModel, Source={StaticResource Locator}}">
                                                <Button ToolTip="Xóa" Command="{Binding DeleteCommand}" CommandParameter="{Binding SelectedItem, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}" Margin="0,0,5,0">
                                                    <Button.Content>
                                                        <Image Source="/Assets/Icons/remove.png"/>
                                                    </Button.Content>
                                                </Button>
                                                <Button ToolTip="Chi tiết" Command="{Binding DetailCommand}" >
                                                    <Button.Content>
                                                        <Image Source="/Assets/Icons/detail.png" />
                                                    </Button.Content>
                                                </Button>
                                            </StackPanel>
                                        </DataTemplate>
                                    </DataGridTemplateColumn.CellTemplate>
                                </DataGridTemplateColumn>
                            </DataGrid.Columns>
                            <DataGrid.RowStyle>
                                <Style TargetType="{x:Type DataGridRow}">
                                    <Setter Property="ContextMenu">
                                        <Setter.Value>
                                            <ContextMenu DataContext="{Binding Main.StaffViewModel, Source={StaticResource Locator}}">
                                                <MenuItem Header="Quá trình công tác" Command="{Binding WorkingHistoryDetailCommand}"/>

                                                <MenuItem Header="Chứng chỉ" Command="{Binding CertificateDetailCommand}"/>

                                                <MenuItem Header="Bảng lương" Command="{Binding SalaryDetailCommand}"/>

                                                <MenuItem Header="Thôi việc" Command="{Binding ResignDetailCommand}"/>

                                                <MenuItem Header="Tham gia dự án" Command="{Binding PPDetailCommand}"/>

                                                <MenuItem Header="Kinh nghiệm" Command="{Binding ExDetailCommand}"/>
                                            </ContextMenu>
                                        </Setter.Value>
                                    </Setter>
                                </Style>
                            </DataGrid.RowStyle>
                        </DataGrid>

                        <local:PagingControl Grid.Row="3" FirstPageCommand="{Binding FirstPageCommand}" PreviosPageCommand="{Binding PreviosPageCommand}" NextPageCommand="{Binding NextPageCommand}" LastPageCommand="{Binding LastPageCommand}" PageIndex="{Binding PageIndex, Mode=TwoWay, UpdateSourceTrigger=Explicit}" PageSize="{Binding PageSize, Mode=TwoWay, UpdateSourceTrigger=Explicit}" NumberOfPages="{Binding NumberOfPages, Mode=OneWay}"/>
                    </Grid>

                    <!--Quản lý dự án para=6-->
                    <Grid Visibility="{Binding SelectedItem, ConverterParameter=6, Converter={StaticResource ConvertFunctionToVisible}, ElementName=lbMain}" DataContext="{Binding ProjectViewModel}">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="*" />
                            <RowDefinition Height="30" />
                        </Grid.RowDefinitions>

                        <Grid Grid.Row="0">
                            <StackPanel Orientation="Horizontal">
                                <GroupBox Header="Tìm theo" Width="Auto" HorizontalAlignment="Left" Margin="0,0,20,0" >
                                    <StackPanel Orientation="Vertical">
                                        <StackPanel Orientation="Horizontal">
                                            <RadioButton Margin="3" IsChecked="{Binding SearchByID, Mode=TwoWay}">Mã dự án</RadioButton>
                                            <RadioButton Margin="3" IsChecked="{Binding SearchByProjectName, Mode=TwoWay}">Tên dự án</RadioButton>
                                        </StackPanel>
                                        <TextBox Margin="0,5,0,5" Style="{StaticResource TextBoxStyle}" Text="{Binding SearchInput, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" >
                                            <TextBox.InputBindings>
                                                <KeyBinding Key="Enter" Command="{Binding SearchCommand}" />
                                            </TextBox.InputBindings>
                                        </TextBox>
                                    </StackPanel>
                                </GroupBox>

                                <GroupBox Header="Chức năng" Padding="5">
                                    <Grid>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition Height="5"/>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition Height="Auto"/>
                                        </Grid.RowDefinitions>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition />
                                            <ColumnDefinition Width="5"/>
                                            <ColumnDefinition Width="200"/>
                                        </Grid.ColumnDefinitions>
                                        <StackPanel Orientation="Horizontal" Grid.Row="0" Grid.ColumnSpan="3">
                                            <RadioButton IsChecked="{Binding AddMode, Mode=TwoWay}" Margin="3">Thêm</RadioButton>
                                            <RadioButton IsChecked="{Binding UpdateMode, Mode=TwoWay}" Margin="3">Sửa</RadioButton>
                                        </StackPanel>
                                        <TextBlock Text="Mã dự án" Grid.Column="0" Grid.Row="1" Style="{StaticResource TextBlockStyle}"/>
                                        <TextBlock Text="Tên dự án" Grid.Column="0" Grid.Row="3" Style="{StaticResource TextBlockStyle}"/>
                                        <TextBox Text="{Binding ProjectIDInput, Mode=TwoWay}" Grid.Column="3" Grid.Row="1" Style="{StaticResource TextBoxStyle}" IsReadOnly="{Binding UpdateMode}"/>
                                        <TextBox Text="{Binding ProjectNameInput, Mode=TwoWay}" Grid.Column="3" Grid.Row="3" Style="{StaticResource TextBoxStyle}"/>

                                    </Grid>
                                </GroupBox>
                            </StackPanel>
                        </Grid>

                        <Grid Grid.Row="1">
                            <ToolBar>
                                <Button Command="{Binding SaveCommand, UpdateSourceTrigger=PropertyChanged}">
                                    <Button.Content>
                                        <StackPanel Orientation="Horizontal">
                                            <Image Source="/Assets/Icons/save.png" Height="20"/>
                                            <TextBlock Text="Lưu" VerticalAlignment="Center" Margin="3,0,3,0" />
                                        </StackPanel>
                                    </Button.Content>

                                </Button>
                                <Button Command="{Binding DeleteListCommand, UpdateSourceTrigger=PropertyChanged}">
                                    <Button.Content>
                                        <StackPanel Orientation="Horizontal">
                                            <Image Source="/Assets/Icons/delete.png" Height="20"/>
                                            <TextBlock Text="Xóa" VerticalAlignment="Center" Margin="3,0,3,0" />
                                        </StackPanel>
                                    </Button.Content>
                                </Button>

                                <Button Command="{Binding RefreshCommand, UpdateSourceTrigger=PropertyChanged}">
                                    <Button.Content>
                                        <StackPanel Orientation="Horizontal">
                                            <Image Source="/Assets/Icons/sync.png" Height="20"/>
                                            <TextBlock Text="Làm tươi" VerticalAlignment="Center" Margin="3,0,3,0" />
                                        </StackPanel>
                                    </Button.Content>
                                </Button>

                                <Button Command="{Binding SearchCommand, UpdateSourceTrigger=PropertyChanged}">
                                    <Button.Content>
                                        <StackPanel Orientation="Horizontal">
                                            <Image Source="/Assets/Icons/search.png" Height="20"/>
                                            <TextBlock Text="Tìm kiếm" VerticalAlignment="Center" Margin="3,0,3,0" />
                                        </StackPanel>
                                    </Button.Content>
                                </Button>
                            </ToolBar>

                            <TextBlock HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,20,0" >
                                <Run Text="Total: " />
                                <Run Text="{Binding TotalItems}" FontWeight="Bold" />
                                <Run Text=" items" />
                            </TextBlock>
                        </Grid>


                        <DataGrid Grid.Row="2" ItemsSource="{Binding Projects, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource DataGridStyle}">
                            <i:Interaction.Triggers>
                                <i:EventTrigger EventName="SelectionChanged">
                                    <i:InvokeCommandAction Command="{Binding DataGridSelectionCommand}" CommandParameter="{Binding SelectedItem, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"/>
                                </i:EventTrigger>
                            </i:Interaction.Triggers>
                            <DataGrid.Columns>
                                <DataGridCheckBoxColumn Binding="{Binding IsChecked, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsReadOnly="False">
                                    <DataGridCheckBoxColumn.HeaderTemplate>
                                        <DataTemplate>
                                            <CheckBox Command="{Binding Main.ProjectViewModel.CheckAllCommand}" DataContext="{StaticResource Locator}" CommandParameter="{Binding IsChecked, RelativeSource={RelativeSource Self}, UpdateSourceTrigger=PropertyChanged}" />
                                        </DataTemplate>
                                    </DataGridCheckBoxColumn.HeaderTemplate>
                                </DataGridCheckBoxColumn>
                                <DataGridTextColumn Header="Mã dự án" Binding="{Binding MaDuAn}" Width="Auto" IsReadOnly="True"/>
                                <DataGridTextColumn Header="Tên dự án" Binding="{Binding TenDuAn}" Width="*" IsReadOnly="True"/>
                                <DataGridTemplateColumn Header="Chức năng">
                                    <DataGridTemplateColumn.CellTemplate>
                                        <DataTemplate>
                                            <Button Content="Xóa" Command="{Binding Main.ProjectViewModel.DeleteCommand}" DataContext="{StaticResource Locator}" CommandParameter="{Binding SelectedItem, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"/>
                                        </DataTemplate>
                                    </DataGridTemplateColumn.CellTemplate>
                                </DataGridTemplateColumn>
                            </DataGrid.Columns>
                        </DataGrid>

                        <local:PagingControl Grid.Row="3" FirstPageCommand="{Binding FirstPageCommand}" PreviosPageCommand="{Binding PreviosPageCommand}" NextPageCommand="{Binding NextPageCommand}" LastPageCommand="{Binding LastPageCommand}" PageIndex="{Binding PageIndex, Mode=TwoWay}" PageSize="{Binding PageSize, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" NumberOfPages="{Binding NumberOfPages, Mode=OneWay}"/>
                    </Grid>

                    <!--Quản lý lương-->
                    <Grid Visibility="{Binding SelectedItem, ConverterParameter=7, Converter={StaticResource ConvertFunctionToVisible}, ElementName=lbMain}" >
                        <!--<Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="*" />
                            <RowDefinition Height="30" />
                        </Grid.RowDefinitions>

                        <Grid Grid.Row="0" Margin="5,0,0,5" >
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="110" />
                            </Grid.ColumnDefinitions>
                            <Grid Grid.Column="0" DataContext="{Binding SelectedItem,Mode=TwoWay}">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="5"/>
                                    <RowDefinition Height="Auto"/>
                                </Grid.RowDefinitions>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="5"/>
                                    <ColumnDefinition Width="150"/>
                                    <ColumnDefinition Width="5"/>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="5"/>
                                    <ColumnDefinition Width="150"/>
                                </Grid.ColumnDefinitions>

                                <StackPanel Grid.Row="0" Grid.ColumnSpan="10" Orientation="Horizontal" DataContext="{Binding SalaryDialog, Source={StaticResource Locator}}" Margin="0,0,0,10">
                                    <RadioButton IsChecked="{Binding AddMode, Mode=TwoWay}" Margin="3">Thêm</RadioButton>
                                    <RadioButton IsChecked="{Binding UpdateMode, Mode=TwoWay}" Margin="3">Sửa</RadioButton>
                                    <TextBlock Text="Nhân viên" Style="{StaticResource TextBlockStyle}" Margin="20,0,0,0" />
                                    <ComboBox ItemsSource="{Binding Staffs}" Selected="{Binding StaffSelected}" Margin="10,0,0,0" MinWidth="100">
                                        <ComboBox.ItemTemplate>
                                            <DataTemplate>
                                                <TextBlock Text="{Binding HoTen}" />
                                            </DataTemplate>
                                        </ComboBox.ItemTemplate>
                                    </ComboBox>
                                </StackPanel>
                                <TextBlock Grid.Row="1" Grid.Column="0" Text="Mã bảng lương" Style="{StaticResource TextBlockStyle}" />
                                <TextBlock Grid.Row="3" Grid.Column="0" Text="Tiền lương" Style="{StaticResource TextBlockStyle}" />

                                <TextBox Grid.Row="1" Grid.Column="2" Text="{Binding MaBangLuong, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource ConvertZeroIDToAutoIndentity}}" Style="{StaticResource TextBoxStyle}"/>
                                <TextBox Grid.Row="3" Grid.Column="2" Text="{Binding TienLuong, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource TextBoxStyle}"/>

                                <TextBlock Grid.Row="1" Grid.Column="4" Text="Tháng" Style="{StaticResource TextBlockStyle}" />

                                <DatePicker Grid.Row="1" Grid.Column="6" Text="{Binding Thang, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                                <TextBlock Grid.Row="3" Grid.Column="4" Text="Trợ cấp" Style="{StaticResource TextBlockStyle}" />
                                <TextBox Grid.Row="3" Grid.Column="6" Text="{Binding TroCap, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource TextBoxStyle}"/>
                            </Grid>
                            <Grid Grid.Column="1" Margin="10">
                                <Image Source="{Binding Staff.AvatarSource}" Height="60"/>
                            </Grid>
                        </Grid>
                        <Grid Grid.Row="1">
                            <ToolBar>
                                <Button Command="{Binding SaveCommand, UpdateSourceTrigger=PropertyChanged}">
                                    <Button.Content>
                                        <StackPanel Orientation="Horizontal">
                                            <Image Source="/Assets/Icons/save.png" Height="20"/>
                                            <TextBlock Text="Lưu" VerticalAlignment="Center" Margin="3,0,3,0" />
                                        </StackPanel>
                                    </Button.Content>

                                </Button>
                                <Button Command="{Binding DeleteListCommand, UpdateSourceTrigger=PropertyChanged}">
                                    <Button.Content>
                                        <StackPanel Orientation="Horizontal">
                                            <Image Source="/Assets/Icons/delete.png" Height="20"/>
                                            <TextBlock Text="Xóa" VerticalAlignment="Center" Margin="3,0,3,0" />
                                        </StackPanel>
                                    </Button.Content>
                                </Button>

                                <Button Command="{Binding RefreshCommand, UpdateSourceTrigger=PropertyChanged}">
                                    <Button.Content>
                                        <StackPanel Orientation="Horizontal">
                                            <Image Source="/Assets/Icons/sync.png" Height="20"/>
                                            <TextBlock Text="Làm tươi" VerticalAlignment="Center" Margin="3,0,3,0" />
                                        </StackPanel>
                                    </Button.Content>
                                </Button>

                            </ToolBar>

                            <TextBlock HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,20,0" >
                                <Run Text="Total: " />
                                <Run Text="{Binding TotalItems}" FontWeight="Bold" />
                                <Run Text=" items" />
                            </TextBlock>
                        </Grid>

                        <DataGrid Grid.Row="2" ItemsSource="{Binding ListEntities, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource DataGridStyle}" SelectedItem="{Binding SelectedItem, Mode=TwoWay}">
                            <DataGrid.Columns>
                                <DataGridCheckBoxColumn Binding="{Binding IsChecked, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsReadOnly="False">
                                    <DataGridCheckBoxColumn.HeaderTemplate>
                                        <DataTemplate>
                                            <CheckBox Command="{Binding SalaryDialog.CheckAllCommand}" DataContext="{StaticResource Locator}" CommandParameter="{Binding IsChecked, RelativeSource={RelativeSource Self}, UpdateSourceTrigger=PropertyChanged}"/>
                                        </DataTemplate>
                                    </DataGridCheckBoxColumn.HeaderTemplate>
                                </DataGridCheckBoxColumn>
                                <DataGridTextColumn Header="Mã bảng lương" Binding="{Binding MaBangLuong}" Width="Auto" IsReadOnly="True"/>
                                <DataGridTextColumn Header="Tiền lương" Binding="{Binding TienLuong, Converter={StaticResource ConvertDecimalToString}}" Width="Auto" IsReadOnly="True"/>
                                <DataGridTextColumn Header="Tháng" Binding="{Binding Thang, Converter={StaticResource ConvertDataTimeToDateString}}" Width="Auto" IsReadOnly="True"/>
                                <DataGridTextColumn Header="Trợ cấp" Binding="{Binding TroCap}" Width="*" IsReadOnly="True"/>
                                <DataGridTextColumn Header="Đơn vị" Binding="{Binding DonVi}" Width="Auto" IsReadOnly="True"/>
                                <DataGridTemplateColumn Header="Chức năng" Width="Auto">
                                    <DataGridTemplateColumn.CellTemplate>
                                        <DataTemplate>
                                            <Button Content="Xóa" Command="{Binding SalaryDialog.DeleteCommand}" DataContext="{StaticResource Locator}" CommandParameter="{Binding SelectedItem, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"/>
                                        </DataTemplate>
                                    </DataGridTemplateColumn.CellTemplate>
                                </DataGridTemplateColumn>
                            </DataGrid.Columns>
                           
                        </DataGrid>

                        <local:PagingControl Grid.Row="3" FirstPageCommand="{Binding FirstPageCommand}" PreviosPageCommand="{Binding PreviosPageCommand}" NextPageCommand="{Binding NextPageCommand}" LastPageCommand="{Binding LastPageCommand}" PageIndex="{Binding PageIndex, Mode=TwoWay}" PageSize="{Binding PageSize, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" NumberOfPages="{Binding NumberOfPages, Mode=OneWay}"/>-->

                    </Grid>

                    <!--Phòng ban id=8-->
                    <Grid Visibility="{Binding SelectedItem, ConverterParameter=8, Converter={StaticResource ConvertFunctionToVisible}, ElementName=lbMain}" DataContext="{Binding DepartmentViewModel}">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="*" />
                            <RowDefinition Height="30" />
                        </Grid.RowDefinitions>

                        <StackPanel Grid.Row="0" Orientation="Horizontal">
                            <GroupBox Header="Chức năng" Padding="5">
                                <Grid d:DataContext="{Binding Departments[0]}" DataContext="{Binding SelectedItem}">
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="5"/>
                                        <RowDefinition Height="Auto"/>
                                    </Grid.RowDefinitions>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition Width="5" />
                                        <ColumnDefinition Width="120" />
                                        <ColumnDefinition Width="5" />
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition Width="5" />
                                        <ColumnDefinition Width="120" />
                                    </Grid.ColumnDefinitions>
                                    <StackPanel Grid.Row="0" Grid.ColumnSpan="10" Orientation="Horizontal" DataContext="{Binding DataContext.DepartmentViewModel, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}">
                                        <RadioButton IsChecked="{Binding AddMode, Mode=TwoWay}" Margin="3">Thêm</RadioButton>
                                        <RadioButton IsChecked="{Binding UpdateMode, Mode=TwoWay}" Margin="3">Sửa</RadioButton>
                                    </StackPanel>
                                    <TextBlock Grid.Row="1" Grid.Column="0" Text="Mã phòng ban" Style="{StaticResource TextBlockStyle}"/>
                                    <TextBlock Grid.Row="3" Grid.Column="0" Text="Tên phòng ban" Style="{StaticResource TextBlockStyle}" />
                                    <TextBox Grid.Row="1" Grid.Column="2" Text="{Binding MaPhongBan}" Style="{StaticResource TextBoxStyle}" IsReadOnly="True"/>
                                    <TextBox Grid.Row="3" Grid.Column="2" Text="{Binding TenPhongBan}" Style="{StaticResource TextBoxStyle}" />

                                    <TextBlock Grid.Row="1" Grid.Column="4" Text="Địa chỉ" Style="{StaticResource TextBlockStyle}"/>
                                    <TextBlock Grid.Row="3" Grid.Column="4" Text="SĐT" Style="{StaticResource TextBlockStyle}" />
                                    <TextBox Grid.Row="1" Grid.Column="6" Text="{Binding DiaChi}" Style="{StaticResource TextBoxStyle}" />
                                    <TextBox Grid.Row="3" Grid.Column="6" Text="{Binding SDT}" Style="{StaticResource TextBoxStyle}" />
                                </Grid>
                            </GroupBox>

                            <GroupBox Header="Tìm kiếm" Padding="5">
                                <StackPanel Orientation="Horizontal">
                                    <StackPanel >
                                        <RadioButton Grid.Row="1" Grid.Column="0" Margin="3" IsChecked="{Binding SearchMode, Converter={StaticResource ConvertDepartmentSearchModeToBoolean}, ConverterParameter=2, Mode=TwoWay}">Tên phòng ban</RadioButton>
                                        <RadioButton Grid.Row="0" Grid.Column="1" Margin="3" IsChecked="{Binding SearchMode, Converter={StaticResource ConvertDepartmentSearchModeToBoolean}, ConverterParameter=3, Mode=TwoWay}">Địa chỉ</RadioButton>
                                        <RadioButton Grid.Row="1" Grid.Column="1" Margin="3" IsChecked="{Binding SearchMode, Converter={StaticResource ConvertDepartmentSearchModeToBoolean}, ConverterParameter=4, Mode=TwoWay}">SDT</RadioButton>
                                    </StackPanel>

                                    <TextBox Width="150" Style="{StaticResource TextBoxStyle}" Text="{Binding SearchInput, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Margin="0,5"/>
                                </StackPanel>
                            </GroupBox>
                        </StackPanel>

                        <Grid Grid.Row="1">
                            <ToolBar>
                                <Button Command="{Binding SaveCommand, UpdateSourceTrigger=PropertyChanged}">
                                    <Button.Content>
                                        <StackPanel Orientation="Horizontal">
                                            <Image Source="/Assets/Icons/save.png" Height="20"/>
                                            <TextBlock Text="Lưu" VerticalAlignment="Center" Margin="3,0,3,0" />
                                        </StackPanel>
                                    </Button.Content>

                                </Button>
                                <Button Command="{Binding DeleteListCommand, UpdateSourceTrigger=PropertyChanged}">
                                    <Button.Content>
                                        <StackPanel Orientation="Horizontal">
                                            <Image Source="/Assets/Icons/delete.png" Height="20"/>
                                            <TextBlock Text="Xóa" VerticalAlignment="Center" Margin="3,0,3,0" />
                                        </StackPanel>
                                    </Button.Content>
                                </Button>

                                <Button Command="{Binding RefreshCommand, UpdateSourceTrigger=PropertyChanged}">
                                    <Button.Content>
                                        <StackPanel Orientation="Horizontal">
                                            <Image Source="/Assets/Icons/sync.png" Height="20"/>
                                            <TextBlock Text="Làm tươi" VerticalAlignment="Center" Margin="3,0,3,0" />
                                        </StackPanel>
                                    </Button.Content>
                                </Button>

                                <Button Command="{Binding SearchCommand, UpdateSourceTrigger=PropertyChanged}">
                                    <Button.Content>
                                        <StackPanel Orientation="Horizontal">
                                            <Image Source="/Assets/Icons/search.png" Height="20"/>
                                            <TextBlock Text="Tìm kiếm" VerticalAlignment="Center" Margin="3,0,3,0" />
                                        </StackPanel>
                                    </Button.Content>
                                </Button>
                            </ToolBar>

                            <TextBlock HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,20,0" >
                                <Run Text="Total: " />
                                <Run Text="{Binding TotalItems}" FontWeight="Bold" />
                                <Run Text=" items" />
                            </TextBlock>
                        </Grid>

                        <DataGrid Grid.Row="2" ItemsSource="{Binding ListEntities, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource DataGridStyle}" SelectedItem="{Binding SelectedItem, Mode=TwoWay}">
                            <DataGrid.Columns>
                                <DataGridCheckBoxColumn Binding="{Binding IsChecked, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsReadOnly="False">
                                    <DataGridCheckBoxColumn.HeaderTemplate>
                                        <DataTemplate>
                                            <CheckBox Command="{Binding Main.DepartmentViewModel.CheckAllCommand}" DataContext="{StaticResource Locator}" CommandParameter="{Binding IsChecked, RelativeSource={RelativeSource Self}, UpdateSourceTrigger=PropertyChanged}"/>
                                        </DataTemplate>
                                    </DataGridCheckBoxColumn.HeaderTemplate>
                                </DataGridCheckBoxColumn>
                                <DataGridTextColumn Header="Mã phòng ban" Binding="{Binding MaPhongBan}" Width="Auto" IsReadOnly="True"/>
                                <DataGridTextColumn Header="Tên phòng ban" Binding="{Binding TenPhongBan}" Width="*" IsReadOnly="True"/>
                                <DataGridTextColumn Header="Địa chỉ" Binding="{Binding DiaChi}" Width="*" IsReadOnly="True"/>
                                <DataGridTextColumn Header="SĐT" Binding="{Binding SDT}" Width="Auto" IsReadOnly="True"/>
                                <DataGridTemplateColumn Header="Chức năng">
                                    <DataGridTemplateColumn.CellTemplate>
                                        <DataTemplate>
                                            <Button Content="Xóa" Command="{Binding Main.DepartmentViewModel.DeleteCommand}" DataContext="{StaticResource Locator}" CommandParameter="{Binding SelectedItem, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"/>
                                        </DataTemplate>
                                    </DataGridTemplateColumn.CellTemplate>
                                </DataGridTemplateColumn>
                            </DataGrid.Columns>
                        </DataGrid>

                        <local:PagingControl Grid.Row="3" FirstPageCommand="{Binding FirstPageCommand}" PreviosPageCommand="{Binding PreviosPageCommand}" NextPageCommand="{Binding NextPageCommand}" LastPageCommand="{Binding LastPageCommand}" PageIndex="{Binding PageIndex, Mode=TwoWay}" PageSize="{Binding PageSize, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" NumberOfPages="{Binding NumberOfPages, Mode=OneWay}"/>
                    </Grid>

                    <Grid Visibility="{Binding SelectedItem, ConverterParameter=9, Converter={StaticResource ConvertFunctionToVisible}, ElementName=lbMain}" DataContext="{Binding EducationViewModel}">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="*" />
                            <RowDefinition Height="30" />
                        </Grid.RowDefinitions>

                        <Grid Grid.Row="0" Margin="5,0,0,5" DataContext="{Binding SelectedItem,Mode=TwoWay}">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="5"/>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="5"/>
                                <ColumnDefinition Width="150"/>
                                <ColumnDefinition Width="5"/>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="5"/>
                                <ColumnDefinition Width="150"/>
                            </Grid.ColumnDefinitions>

                            <StackPanel Grid.Row="0" Grid.ColumnSpan="10" Orientation="Horizontal" DataContext="{Binding DataContext.EducationViewModel, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}">
                                <RadioButton IsChecked="{Binding AddMode, Mode=TwoWay}" Margin="3">Thêm</RadioButton>
                                <RadioButton IsChecked="{Binding UpdateMode, Mode=TwoWay}" Margin="3">Sửa</RadioButton>
                            </StackPanel>
                            <TextBlock Grid.Row="1" Grid.Column="0" Text="Mã Trình Độ" Style="{StaticResource TextBlockStyle}" />
                            <TextBlock Grid.Row="3" Grid.Column="0" Text="Tên Trình Độ" Style="{StaticResource TextBlockStyle}" />

                            <TextBox Grid.Row="1" Grid.Column="2" Text="{Binding MaTrinhDo}" Style="{StaticResource TextBoxStyle}" />
                            <TextBox Grid.Row="3" Grid.Column="2" Text="{Binding TenTrinhDo}" Style="{StaticResource TextBoxStyle}" />

                            <TextBlock Grid.Row="1" Grid.Column="4" Text="Chuyên ngành" Style="{StaticResource TextBlockStyle}" />
                            <TextBox Grid.Row="1" Grid.Column="6" Text="{Binding ChuyenNganh}" Style="{StaticResource TextBoxStyle}" />
                        </Grid>

                        <Grid Grid.Row="1">
                            <ToolBar>
                                <Button Command="{Binding SaveCommand, UpdateSourceTrigger=PropertyChanged}">
                                    <Button.Content>
                                        <StackPanel Orientation="Horizontal">
                                            <Image Source="/Assets/Icons/save.png" Height="20"/>
                                            <TextBlock Text="Lưu" VerticalAlignment="Center" Margin="3,0,3,0" />
                                        </StackPanel>
                                    </Button.Content>

                                </Button>
                                <Button Command="{Binding DeleteListCommand, UpdateSourceTrigger=PropertyChanged}">
                                    <Button.Content>
                                        <StackPanel Orientation="Horizontal">
                                            <Image Source="/Assets/Icons/delete.png" Height="20"/>
                                            <TextBlock Text="Xóa" VerticalAlignment="Center" Margin="3,0,3,0" />
                                        </StackPanel>
                                    </Button.Content>
                                </Button>

                                <Button Command="{Binding RefreshCommand, UpdateSourceTrigger=PropertyChanged}">
                                    <Button.Content>
                                        <StackPanel Orientation="Horizontal">
                                            <Image Source="/Assets/Icons/sync.png" Height="20"/>
                                            <TextBlock Text="Làm tươi" VerticalAlignment="Center" Margin="3,0,3,0" />
                                        </StackPanel>
                                    </Button.Content>
                                </Button>

                            </ToolBar>

                            <TextBlock HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,20,0" >
                                <Run Text="Total: " />
                                <Run Text="{Binding TotalItems}" FontWeight="Bold" />
                                <Run Text=" items" />
                            </TextBlock>
                        </Grid>

                        <DataGrid Grid.Row="2" ItemsSource="{Binding ListEntities, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource DataGridStyle}" SelectedItem="{Binding SelectedItem, Mode=TwoWay}">
                            <DataGrid.Columns>
                                <DataGridCheckBoxColumn Binding="{Binding IsChecked, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsReadOnly="False">
                                    <DataGridCheckBoxColumn.HeaderTemplate>
                                        <DataTemplate>
                                            <CheckBox Command="{Binding Main.EducationViewModel.CheckAllCommand}" DataContext="{StaticResource Locator}" CommandParameter="{Binding IsChecked, RelativeSource={RelativeSource Self}, UpdateSourceTrigger=PropertyChanged}"/>
                                        </DataTemplate>
                                    </DataGridCheckBoxColumn.HeaderTemplate>
                                </DataGridCheckBoxColumn>
                                <DataGridTextColumn Header="Mã trình độ" Binding="{Binding MaTrinhDo}" Width="Auto" IsReadOnly="True"/>
                                <DataGridTextColumn Header="Tên trình độ" Binding="{Binding TenTrinhDo}" Width="*" IsReadOnly="True"/>
                                <DataGridTextColumn Header="Chuyên ngành" Binding="{Binding ChuyenNganh}" Width="*" IsReadOnly="True"/>
                                <DataGridTemplateColumn Header="Chức năng">
                                    <DataGridTemplateColumn.CellTemplate>
                                        <DataTemplate>
                                            <Button Content="Xóa" Command="{Binding Main.EducationViewModel.DeleteCommand}" DataContext="{StaticResource Locator}" CommandParameter="{Binding SelectedItem, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"/>
                                        </DataTemplate>
                                    </DataGridTemplateColumn.CellTemplate>
                                </DataGridTemplateColumn>
                            </DataGrid.Columns>
                        </DataGrid>

                        <local:PagingControl Grid.Row="3" FirstPageCommand="{Binding FirstPageCommand}" PreviosPageCommand="{Binding PreviosPageCommand}" NextPageCommand="{Binding NextPageCommand}" LastPageCommand="{Binding LastPageCommand}" PageIndex="{Binding PageIndex, Mode=TwoWay}" PageSize="{Binding PageSize, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" NumberOfPages="{Binding NumberOfPages, Mode=OneWay}"/>
                    </Grid>

                    <Grid Visibility="{Binding SelectedItem, ConverterParameter=10, Converter={StaticResource ConvertFunctionToVisible}, ElementName=lbMain}" DataContext="{Binding RegencyViewModel}">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="*" />
                            <RowDefinition Height="30" />
                        </Grid.RowDefinitions>

                        <Grid Grid.Row="0" Margin="5,0,0,5" DataContext="{Binding SelectedItem,Mode=TwoWay}">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="5"/>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="5"/>
                                <ColumnDefinition Width="150"/>
                                <ColumnDefinition Width="5"/>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="5"/>
                                <ColumnDefinition Width="150"/>
                            </Grid.ColumnDefinitions>

                            <StackPanel Grid.Row="0" Grid.ColumnSpan="10" Orientation="Horizontal" DataContext="{Binding DataContext.RegencyViewModel, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}">
                                <RadioButton IsChecked="{Binding AddMode, Mode=TwoWay}" Margin="3">Thêm</RadioButton>
                                <RadioButton IsChecked="{Binding UpdateMode, Mode=TwoWay}" Margin="3">Sửa</RadioButton>
                            </StackPanel>
                            <TextBlock Grid.Row="1" Grid.Column="0" Text="Mã chức vụ" Style="{StaticResource TextBlockStyle}" />
                            <TextBlock Grid.Row="3" Grid.Column="0" Text="Tên chức vụ" Style="{StaticResource TextBlockStyle}" />

                            <TextBox Grid.Row="1" Grid.Column="2" Text="{Binding MaChucVu}" Style="{StaticResource TextBoxStyle}" IsReadOnly="True"/>
                            <TextBox Grid.Row="3" Grid.Column="2" Text="{Binding TenChuVu, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource TextBoxStyle}" />
                        </Grid>

                        <Grid Grid.Row="1">
                            <ToolBar>
                                <Button Command="{Binding SaveCommand, UpdateSourceTrigger=PropertyChanged}">
                                    <Button.Content>
                                        <StackPanel Orientation="Horizontal">
                                            <Image Source="/Assets/Icons/save.png" Height="20"/>
                                            <TextBlock Text="Lưu" VerticalAlignment="Center" Margin="3,0,3,0" />
                                        </StackPanel>
                                    </Button.Content>

                                </Button>
                                <Button Command="{Binding DeleteListCommand, UpdateSourceTrigger=PropertyChanged}">
                                    <Button.Content>
                                        <StackPanel Orientation="Horizontal">
                                            <Image Source="/Assets/Icons/delete.png" Height="20"/>
                                            <TextBlock Text="Xóa" VerticalAlignment="Center" Margin="3,0,3,0" />
                                        </StackPanel>
                                    </Button.Content>
                                </Button>

                                <Button Command="{Binding RefreshCommand, UpdateSourceTrigger=PropertyChanged}">
                                    <Button.Content>
                                        <StackPanel Orientation="Horizontal">
                                            <Image Source="/Assets/Icons/sync.png" Height="20"/>
                                            <TextBlock Text="Làm tươi" VerticalAlignment="Center" Margin="3,0,3,0" />
                                        </StackPanel>
                                    </Button.Content>
                                </Button>

                            </ToolBar>

                            <TextBlock HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,20,0" >
                                <Run Text="Total: " />
                                <Run Text="{Binding TotalItems}" FontWeight="Bold" />
                                <Run Text=" items" />
                            </TextBlock>
                        </Grid>

                        <DataGrid Grid.Row="2" ItemsSource="{Binding ListEntities, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource DataGridStyle}" SelectedItem="{Binding SelectedItem, Mode=TwoWay}">
                            <DataGrid.Columns>
                                <DataGridCheckBoxColumn Binding="{Binding IsChecked, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsReadOnly="False">
                                    <DataGridCheckBoxColumn.HeaderTemplate>
                                        <DataTemplate>
                                            <CheckBox Command="{Binding Main.RegencyViewModel.CheckAllCommand}" DataContext="{StaticResource Locator}" CommandParameter="{Binding IsChecked, RelativeSource={RelativeSource Self}, UpdateSourceTrigger=PropertyChanged}"/>
                                        </DataTemplate>
                                    </DataGridCheckBoxColumn.HeaderTemplate>
                                </DataGridCheckBoxColumn>
                                <DataGridTextColumn Header="Mã chức vụ" Binding="{Binding MaChucVu}" Width="Auto" IsReadOnly="True"/>
                                <DataGridTextColumn Header="Tên chức vụ" Binding="{Binding TenChuVu}" Width="*" IsReadOnly="True"/>
                                <DataGridTemplateColumn Header="Chức năng">
                                    <DataGridTemplateColumn.CellTemplate>
                                        <DataTemplate>
                                            <Button Content="Xóa" Command="{Binding Main.RegencyViewModel.DeleteCommand}" DataContext="{StaticResource Locator}" CommandParameter="{Binding SelectedItem, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"/>
                                        </DataTemplate>
                                    </DataGridTemplateColumn.CellTemplate>
                                </DataGridTemplateColumn>
                            </DataGrid.Columns>
                        </DataGrid>

                        <local:PagingControl Grid.Row="3" FirstPageCommand="{Binding FirstPageCommand}" PreviosPageCommand="{Binding PreviosPageCommand}" NextPageCommand="{Binding NextPageCommand}" LastPageCommand="{Binding LastPageCommand}" PageIndex="{Binding PageIndex, Mode=TwoWay}" PageSize="{Binding PageSize, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" NumberOfPages="{Binding NumberOfPages, Mode=OneWay}"/>
                    </Grid>

                    <Grid Visibility="{Binding SelectedItem, ConverterParameter=11, Converter={StaticResource ConvertFunctionToVisible}, ElementName=lbMain}" DataContext="{Binding CategoryCertificateViewModel}">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="*" />
                            <RowDefinition Height="30" />
                        </Grid.RowDefinitions>

                        <Grid Grid.Row="0" Margin="5,0,0,5" DataContext="{Binding SelectedItem,Mode=TwoWay}">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="5"/>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="5"/>
                                <ColumnDefinition Width="150"/>
                                <ColumnDefinition Width="5"/>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="5"/>
                                <ColumnDefinition Width="150"/>
                            </Grid.ColumnDefinitions>

                            <StackPanel Grid.Row="0" Grid.ColumnSpan="10" Orientation="Horizontal" DataContext="{Binding DataContext.CategoryCertificateViewModel, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}">
                                <RadioButton IsChecked="{Binding AddMode, Mode=TwoWay}" Margin="3">Thêm</RadioButton>
                                <RadioButton IsChecked="{Binding UpdateMode, Mode=TwoWay}" Margin="3">Sửa</RadioButton>
                            </StackPanel>
                            <TextBlock Grid.Row="1" Grid.Column="0" Text="Mã DM chứng chỉ" Style="{StaticResource TextBlockStyle}" />
                            <TextBlock Grid.Row="3" Grid.Column="0" Text="Tên chứng chỉ" Style="{StaticResource TextBlockStyle}" />

                            <TextBox Grid.Row="1" Grid.Column="2" Text="{Binding MaDMChungChi}" Style="{StaticResource TextBoxStyle}" IsReadOnly="True"/>
                            <TextBox Grid.Row="3" Grid.Column="2" Text="{Binding TenChungChi, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource TextBoxStyle}" />

                            <TextBlock Grid.Row="1" Grid.Column="4" Text="Chuyên ngành" Style="{StaticResource TextBlockStyle}" />
                            <TextBox Grid.Row="1" Grid.Column="6" Text="{Binding ChuyenNganh}" Style="{StaticResource TextBoxStyle}" IsReadOnly="True"/>
                        </Grid>

                        <Grid Grid.Row="1">
                            <ToolBar>
                                <Button Command="{Binding SaveCommand, UpdateSourceTrigger=PropertyChanged}">
                                    <Button.Content>
                                        <StackPanel Orientation="Horizontal">
                                            <Image Source="/Assets/Icons/save.png" Height="20"/>
                                            <TextBlock Text="Lưu" VerticalAlignment="Center" Margin="3,0,3,0" />
                                        </StackPanel>
                                    </Button.Content>

                                </Button>
                                <Button Command="{Binding DeleteListCommand, UpdateSourceTrigger=PropertyChanged}">
                                    <Button.Content>
                                        <StackPanel Orientation="Horizontal">
                                            <Image Source="/Assets/Icons/delete.png" Height="20"/>
                                            <TextBlock Text="Xóa" VerticalAlignment="Center" Margin="3,0,3,0" />
                                        </StackPanel>
                                    </Button.Content>
                                </Button>

                                <Button Command="{Binding RefreshCommand, UpdateSourceTrigger=PropertyChanged}">
                                    <Button.Content>
                                        <StackPanel Orientation="Horizontal">
                                            <Image Source="/Assets/Icons/sync.png" Height="20"/>
                                            <TextBlock Text="Làm tươi" VerticalAlignment="Center" Margin="3,0,3,0" />
                                        </StackPanel>
                                    </Button.Content>
                                </Button>

                            </ToolBar>

                            <TextBlock HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,20,0" >
                                <Run Text="Total: " />
                                <Run Text="{Binding TotalItems}" FontWeight="Bold" />
                                <Run Text=" items" />
                            </TextBlock>
                        </Grid>

                        <DataGrid Grid.Row="2" ItemsSource="{Binding ListEntities, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource DataGridStyle}" SelectedItem="{Binding SelectedItem, Mode=TwoWay}">
                            <DataGrid.Columns>
                                <DataGridCheckBoxColumn Binding="{Binding IsChecked, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsReadOnly="False">
                                    <DataGridCheckBoxColumn.HeaderTemplate>
                                        <DataTemplate>
                                            <CheckBox Command="{Binding Main.CategoryCertificateViewModel.CheckAllCommand}" DataContext="{StaticResource Locator}" CommandParameter="{Binding IsChecked, RelativeSource={RelativeSource Self}, UpdateSourceTrigger=PropertyChanged}"/>
                                        </DataTemplate>
                                    </DataGridCheckBoxColumn.HeaderTemplate>
                                </DataGridCheckBoxColumn>
                                <DataGridTextColumn Header="Mã d" Binding="{Binding MaDMChungChi}" Width="Auto" IsReadOnly="True"/>
                                <DataGridTextColumn Header="Tên chức vụ" Binding="{Binding TenChungChi}" Width="*" IsReadOnly="True"/>
                                <DataGridTextColumn Header="Tên chức vụ" Binding="{Binding ChuyenNganh}" Width="*" IsReadOnly="True"/>
                                <DataGridTemplateColumn Header="Chức năng">
                                    <DataGridTemplateColumn.CellTemplate>
                                        <DataTemplate>
                                            <Button Content="Xóa" Command="{Binding Main.CategoryCertificateViewModel.DeleteCommand}" DataContext="{StaticResource Locator}" CommandParameter="{Binding SelectedItem, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"/>
                                        </DataTemplate>
                                    </DataGridTemplateColumn.CellTemplate>
                                </DataGridTemplateColumn>
                            </DataGrid.Columns>
                        </DataGrid>

                        <local:PagingControl Grid.Row="3" FirstPageCommand="{Binding FirstPageCommand}" PreviosPageCommand="{Binding PreviosPageCommand}" NextPageCommand="{Binding NextPageCommand}" LastPageCommand="{Binding LastPageCommand}" PageIndex="{Binding PageIndex, Mode=TwoWay}" PageSize="{Binding PageSize, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" NumberOfPages="{Binding NumberOfPages, Mode=OneWay}"/>
                    </Grid>

                    <Grid Visibility="{Binding SelectedItem, ConverterParameter=12, Converter={StaticResource ConvertFunctionToVisible}, ElementName=lbMain}" DataContext="{Binding PieceSalaryBonusViewModel}">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="*" />
                            <RowDefinition Height="30" />
                        </Grid.RowDefinitions>

                        <Grid Grid.Row="0" Margin="5,0,0,5" DataContext="{Binding SelectedItem,Mode=TwoWay}">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="5"/>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="5"/>
                                <ColumnDefinition Width="150"/>
                                <ColumnDefinition Width="5"/>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="5"/>
                                <ColumnDefinition Width="150"/>
                            </Grid.ColumnDefinitions>

                            <StackPanel Grid.Row="0" Grid.ColumnSpan="10" Orientation="Horizontal" DataContext="{Binding DataContext.PieceSalaryBonusViewModel, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}">
                                <RadioButton IsChecked="{Binding AddMode, Mode=TwoWay}" Margin="3">Thêm</RadioButton>
                                <RadioButton IsChecked="{Binding UpdateMode, Mode=TwoWay}" Margin="3">Sửa</RadioButton>
                            </StackPanel>
                            <TextBlock Grid.Row="1" Grid.Column="0" Text="Mã chức vụ" Style="{StaticResource TextBlockStyle}" />
                            <TextBlock Grid.Row="3" Grid.Column="0" Text="Tên chức vụ" Style="{StaticResource TextBlockStyle}" />

                            <TextBox Grid.Row="1" Grid.Column="2" Text="{Binding MaLoai}" Style="{StaticResource TextBoxStyle}" IsReadOnly="True"/>
                            <TextBox Grid.Row="3" Grid.Column="2" Text="{Binding TenLoaiLuong, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource TextBoxStyle}" />
                        </Grid>

                        <Grid Grid.Row="1">
                            <ToolBar>
                                <Button Command="{Binding SaveCommand, UpdateSourceTrigger=PropertyChanged}">
                                    <Button.Content>
                                        <StackPanel Orientation="Horizontal">
                                            <Image Source="/Assets/Icons/save.png" Height="20"/>
                                            <TextBlock Text="Lưu" VerticalAlignment="Center" Margin="3,0,3,0" />
                                        </StackPanel>
                                    </Button.Content>

                                </Button>
                                <Button Command="{Binding DeleteListCommand, UpdateSourceTrigger=PropertyChanged}">
                                    <Button.Content>
                                        <StackPanel Orientation="Horizontal">
                                            <Image Source="/Assets/Icons/delete.png" Height="20"/>
                                            <TextBlock Text="Xóa" VerticalAlignment="Center" Margin="3,0,3,0" />
                                        </StackPanel>
                                    </Button.Content>
                                </Button>

                                <Button Command="{Binding RefreshCommand, UpdateSourceTrigger=PropertyChanged}">
                                    <Button.Content>
                                        <StackPanel Orientation="Horizontal">
                                            <Image Source="/Assets/Icons/sync.png" Height="20"/>
                                            <TextBlock Text="Làm tươi" VerticalAlignment="Center" Margin="3,0,3,0" />
                                        </StackPanel>
                                    </Button.Content>
                                </Button>

                            </ToolBar>

                            <TextBlock HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,20,0" >
                                <Run Text="Total: " />
                                <Run Text="{Binding TotalItems}" FontWeight="Bold" />
                                <Run Text=" items" />
                            </TextBlock>
                        </Grid>

                        <DataGrid Grid.Row="2" ItemsSource="{Binding ListEntities, UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource DataGridStyle}" SelectedItem="{Binding SelectedItem, Mode=TwoWay}">
                            <DataGrid.Columns>
                                <DataGridCheckBoxColumn Binding="{Binding IsChecked, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsReadOnly="False">
                                    <DataGridCheckBoxColumn.HeaderTemplate>
                                        <DataTemplate>
                                            <CheckBox Command="{Binding Main.PieceSalaryBonusViewModel.CheckAllCommand}" DataContext="{StaticResource Locator}" CommandParameter="{Binding IsChecked, RelativeSource={RelativeSource Self}, UpdateSourceTrigger=PropertyChanged}"/>
                                        </DataTemplate>
                                    </DataGridCheckBoxColumn.HeaderTemplate>
                                </DataGridCheckBoxColumn>
                                <DataGridTextColumn Header="Mã d" Binding="{Binding MaLoai}" Width="Auto" IsReadOnly="True"/>
                                <DataGridTextColumn Header="Tên chức vụ" Binding="{Binding TenLoaiLuong}" Width="*" IsReadOnly="True"/>
                                <DataGridTemplateColumn Header="Chức năng">
                                    <DataGridTemplateColumn.CellTemplate>
                                        <DataTemplate>
                                            <Button Content="Xóa" Command="{Binding Main.PieceSalaryBonusViewModel.DeleteCommand}" DataContext="{StaticResource Locator}" CommandParameter="{Binding SelectedItem, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"/>
                                        </DataTemplate>
                                    </DataGridTemplateColumn.CellTemplate>
                                </DataGridTemplateColumn>
                            </DataGrid.Columns>
                        </DataGrid>

                        <local:PagingControl Grid.Row="3" FirstPageCommand="{Binding FirstPageCommand}" PreviosPageCommand="{Binding PreviosPageCommand}" NextPageCommand="{Binding NextPageCommand}" LastPageCommand="{Binding LastPageCommand}" PageIndex="{Binding PageIndex, Mode=TwoWay}" PageSize="{Binding PageSize, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" NumberOfPages="{Binding NumberOfPages, Mode=OneWay}"/>
                    </Grid>
                </Grid>

                <!--Status bar-->
                <Grid Grid.Row="1" Background="{DynamicResource {x:Static SystemColors.ControlLightBrushKey}}">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <local:StatusControl Grid.Column="0" x:Name="Status" />
                    <StackPanel Grid.Column="1" HorizontalAlignment="Right" Orientation="Horizontal" Margin="0,0,30,0" VerticalAlignment="Stretch">
                        <TextBlock Text="Welcome: " VerticalAlignment="Center"/>
                        <TextBlock Text="{Binding User.TenDangNhap}" FontFamily="Myriad Pro" VerticalAlignment="Center" Foreground="Red" FontSize="18" HorizontalAlignment="Left" />
                    </StackPanel>
                </Grid>

            </Grid>
        </Grid>
    </Grid>
</Window>
